using UnityEngine;
using System.Collections;

public class PitfallDeath : MonoBehaviour {
	
	public GameObject car;
	Vector3 carPosition;
	Quaternion carRotation;
	
	// Use this for initialization
	void Start () {
		carPosition = car.transform.position;
		carRotation = car.transform.rotation;
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnCollisionEnter(Collision c){
		// only move player
		if (GenerateObjects.getPlayer() == c.gameObject) {
			// respawn him
			c.gameObject.GetComponent<CharacterManager>().respawn();
			c.rigidbody.velocity = Vector3.zero;
			// reset car?
			car.transform.position = carPosition;
			car.transform.rotation = carRotation;
			car.GetComponent<CarDrive>().drive = false;
			car.rigidbody.velocity = Vector3.zero;
			car.rigidbody.angularVelocity = Vector3.zero;
		}
		
		car.transform.position = carPosition;
		car.transform.rotation = carRotation;
		car.GetComponent<CarDrive>().drive = false;
		car.rigidbody.velocity = Vector3.zero;
		car.rigidbody.angularVelocity = Vector3.zero;
		
	}
}
